<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2021/11/6
 * Time: 14:39
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

declare(strict_types=1);

namespace app\admin\controller;

use app\common\business\PlaceOrder;
use app\common\business\Wechat;
use app\common\lib\Show;
use app\common\lib\Status;
use app\common\lib\Time;

class Welcome extends Base
{
    public function index()
    {
        return $this->fetch();
    }

    public function getWelcomeByList()
    {
        //获取首页
        //用户统计
        $time = Time::month();
        $where = [
            ['create_time', 'between', $time]
        ];

        try {
            //用户统计
            $count = (new Wechat())->getIndexWechatByCount($where);
            //演出统计
            $whereTheatre = [
                ['start_time', 'between', $time]
            ];
            $theatre = (new \app\common\business\Theatre())->getTheatreByCount($whereTheatre);
            //查询订单
            $order = (new PlaceOrder())->getOrderByCount($where);
        } catch (\Exception $e) {
            return Show::json_show(Status::mini_error, $e->getMessage());
        }


        $lists = [
            "wechat" => $count,
            "theatre" => $theatre,
            "order" => $order
        ];
        return Show::json_show(Status::status_normal, "ok", $lists);
    }
}